﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Branches
/// </summary>
public class Branch :IBusinessEntity
{
	
    #region variables
        private string _pinCode;
        private string _branchAddress;
        private string _branchName;
        private string _branchFax;
        private string _branchPhone;
        private string _cityID;
    #endregion

    #region constructors
    public Branch()
    {
        _pinCode = String.Empty;
        _branchAddress = String.Empty;
        _branchName = String.Empty;
        _branchFax = String.Empty;
        _branchPhone = String.Empty;
        _cityID = String.Empty;
    }

    public Branch(string pinCode, string branchName, string branchFax, 
        string branchPhone, string branchAddress, string cityID)
    {
        _pinCode =pinCode;
        _branchAddress = branchAddress;
        _branchName = branchName;
        _branchFax = branchFax;
        _branchPhone = branchPhone;
        _cityID = cityID;
    }
    #endregion


    #region Property
        public string PinCode
        {
            get { return _pinCode; }
            set { _pinCode = value; }
        }
        public string BranchAddress
        {
            get { return _branchAddress; }
            set { _branchAddress = value; }
        }
        public string BranchName
        {
            get { return _branchName; }
            set { _branchName = value; }
        }
        public string BranchFax
        {
            get { return _branchFax; }
            set { _branchFax = value; }
        }
        public string BranchPhone
        {
            get { return _branchPhone; }
            set { _branchPhone = value; }
        }
        public string CityID
        {
            get { return _cityID; }
            set { _cityID = value; }
        }
    #endregion

    #region Method
    public void Fill(SqlDataReader reader)
    {
        if (DAL.ColumnExists(reader, "PinCode"))
        _pinCode = reader.GetString(0);
        if (DAL.ColumnExists(reader, "BranchAddress"))
        _branchAddress = reader.GetString(1);
        if (DAL.ColumnExists(reader, "BranchName"))
        _branchName=reader.GetString(2);
        if (DAL.ColumnExists(reader, "BranchFax") && !reader.IsDBNull(3))
        _branchFax = reader.GetString(3);
        if (DAL.ColumnExists(reader, "BranchPhone") && !reader.IsDBNull(4))
        _branchPhone=reader.GetString(4);
        if (DAL.ColumnExists(reader, "CityID"))
        _cityID = reader.GetInt32(5).ToString();
    }
    #endregion
}
